package com.bankcomm.ui.specialwidget;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.bankcomm.R;
import com.bankcomm.ui.BaseViewCopy;
import com.rytong.tools.ui.Component;
import com.rytong.tools.utils.Utils;

public class LPCoinConversion extends Component {
	private String[] imgs_;

	@Override
	public void initRealView(Activity activity, String nodeValue) {
		realView_ = new MyLPCoinConversion(activity);
		super.initRealView(activity, nodeValue);
	}

	public class MyLPCoinConversion extends FrameLayout {
		BaseViewCopy bvc_;
		
		public MyLPCoinConversion(Context context) {
			super(context);
			this.bvc_ = (BaseViewCopy) context;
			
			setFocusable(true);

			imgs_ = getData();
			
			View view = LayoutInflater.from(bvc_).inflate(R.layout.coin, null);
			ImageView img_o = (ImageView) view.findViewById(R.id.imgO);
			ImageView img_t = (ImageView) view.findViewById(R.id.imgT);
			Bitmap bitmap = null;
			if (imgs_ != null && imgs_.length > 0) {
				bitmap = Utils.getBitmapFromResources(bvc_, imgs_[0]);
				img_o.setImageBitmap(bitmap);
				bitmap = Utils.getBitmapFromResources(bvc_, imgs_[1]);
				img_t.setImageBitmap(bitmap);
			}
			
			addView(view);
		}
		
	}
	
	String[] getData(){
		String imgUrl = getPropertyByName("coins");
		Utils.printOutToConsole(imgUrl);
		String[] imgs = null;
		if (imgUrl != null && imgUrl.length() > 0) {
			imgs = imgUrl.split(",");
		}
		return imgs;
	}
}
